package com.prs.crm.action.sys;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.domain.sys.LeadEmailAnonymity;
import com.prs.crm.domain.sys.WeatherAnonymity;
import com.prs.crm.service.sys.WeatherAnonymityService;

public class WeatherAnonymityAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private WeatherAnonymity weatherAnonymity;
	private WeatherAnonymityService weatherAnonymityService;
	private PaginationSupport pagination;

	public WeatherAnonymity getWeatherAnonymity() {
		return weatherAnonymity;
	}
	public void setWeatherAnonymity(WeatherAnonymity weatherAnonymity) {
		this.weatherAnonymity = weatherAnonymity;
	}
	public WeatherAnonymityService getWeatherAnonymityService() {
		return weatherAnonymityService;
	}
	public void setWeatherAnonymityService(
			WeatherAnonymityService weatherAnonymityService) {
		this.weatherAnonymityService = weatherAnonymityService;
	}
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	
	@Action("listWeatherAnonymity")
	public String listWeatherAnonymity(){
		DetachedCriteria criteria =this.getPaginationHelper().createQuery(WeatherAnonymity.class);
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getWeatherAnonymityService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	@Action(value = "saveWeatherAnonymity", results = {
			@Result(name = "success", type = "redirect", location = "listWeatherAnonymity"),
			@Result(name = "error", type = "chain", location = "listWeatherAnonymity")})
	public String saveWeatherAnonymity(){
		weatherAnonymity.setState(0);
		this.getWeatherAnonymityService().submit(weatherAnonymity);
		return SUCCESS;
	}
	@Action(value = "saveWeatherAnonymitys", results = {
			@Result(name = "success", type = "redirect", location = "listWeatherAnonymity"),
			@Result(name = "error", type = "chain", location = "listWeatherAnonymity")})
	public String saveWeatherAnonymitys(){
		weatherAnonymity.setState(1);
		this.getWeatherAnonymityService().submit(weatherAnonymity);
		return SUCCESS;
	}
}
